package syscore_service

import (
	"github.com/EDDYCJY/go-gin-example/models"
)

type GetStreamer struct {
	InstitutionID int
	PageNum       int
	PageSize      int
}

func (t *GetStreamer) GetStreamer() (interface{}, error) {
	maps := map[string]interface{}{}
	total, _ := models.GetStreamerTotal(maps)
	streamerList, _ := models.GetStreamerPage([]string{"streamer_name", "streamer_mobile", "streamer_id"}, maps, t.PageNum, t.PageSize, "")
	var lists []interface{}
	for _, v := range streamerList {

		var streamer_tag []interface{}
		for _, v1 := range v.StreamerTag {
			var tag = map[string]interface{}{
				"tag_id":   v1.TagID,
				"tag_name": v1.Tag.TagName,
			}
			streamer_tag = append(streamer_tag, tag)
		}
		params := map[string]interface{}{
			"streamer_id":     v.StreamerId,
			"streamer_mobile": v.StreamerMobile,
			"streamer_name":   v.StreamerName,
			"streamer_tag":    streamer_tag,
		}
		lists = append(lists, params)
	}
	return map[string]interface{}{
		"lists": lists,
		"total": total,
	}, nil
}
